const Koa = require('koa')
const app = new Koa()
const serve = require('koa-static')
const { historyApiFallback }  = require('koa2-connect-history-api-fallback')
const proxy = require('koa2-proxy-middleware')

app.use(proxy({
  targets:{
    '/prod-api/(.*)': {
      target: 'http://ihrm-java.itheima.net/api',
      // target: 'http://liufusong.top:3000/api',
      changeOrigin: true,
      pathRewrite: {
        '/prod-api': ''
      }
    }
  }
}))
app.use(historyApiFallback({
  whiteList: ['/prod-api']
})) // 必须放在静态化服务前面
app.use(serve(__dirname + '/public')) // 静态化服务

app.listen(3333, function() {
  console.log('人资项目启动成功')
})